﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using AcctruePMS.Bll;
using AcctrueWMS.Foundation.DAL;
namespace AcctrueWMS.Web
{
    public partial class dopost_projectQuestion : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["accType"] != null)
            {//项目报告的操作
            
                    Response.Write(SaveOfUpdateProjectQuestion());
                    Response.End();
            }
        }

        /// <summary>
        /// 对项目的分解项数据的保存
        /// </summary>
        /// <returns></returns>
        private string SaveOfUpdateProjectQuestion() {

            StringBuilder sb = new StringBuilder();
            List<SqlParameter> pL = new List<SqlParameter>();
            string projectGUID = Request.Form["projectGUID"];//获取项目ID
            string[] symbol = {"(%)"};//每一项的分隔符
            string[] symbol1={"(@)"};//每一项中值的分隔符
            string[] item = Request.Form["data"].Split(symbol, StringSplitOptions.None);
            try
            {
                for (int i = 0; i < item.Length; i++)
                {
                    string[] value = item[i].Split(symbol1, StringSplitOptions.None);
                    sb.Append("update dbo.projectdismemberment set execDesc=@execDesc");
                    sb.Append(i);
                    sb.Append(",itemChecked=");
                    sb.Append(value[2]);
                    sb.Append(" where itemName='");
                    sb.Append(value[0]);
                    sb.Append("' and projectGUID='");
                    sb.Append(projectGUID);
                    sb.Append("';");
                    SqlParameter par = new SqlParameter("@execDesc" + i, SqlDbType.NVarChar, 2000);
                    par.Value = value[1];
                    pL.Add(par);
                }
            }
            catch (Exception ex)
            {

                return "false";
            }
           WMSqlExcuter.ExecuteNonQuery(sb.ToString(),CommandType.Text,pL.ToArray());
           
           return "true";
          
        }


      
    }
}